{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "## Pandas",
   "id": "75482f5ae53f3093"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "#### 什么是Pandas",
   "id": "e4040c74df808377"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "Pandas 是基于 NumPy 的一种工具，该工具是为解决数据分析任务而创建的。Pandas 纳入了大量库和一些标准的数据模型，提供了高效地操作大型数据集所需的工具。\n",
    "\n",
    "pandas 有两个主要的数据结构，Series 和 DataFrame，记住大小写区分。"
   ],
   "id": "2d97410384e09a8c"
  },
  {
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-01-25T13:26:28.198122Z",
     "start_time": "2025-01-25T13:26:27.958248Z"
    }
   },
   "cell_type": "code",
   "source": "import pandas as pd",
   "id": "initial_id",
   "outputs": [],
   "execution_count": 1
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "#### Series",
   "id": "12ac302f866791cc"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "Series 类似于一维数组，和 numpy 的 ndarray 接近，由一组数据和数据标签组成。数据标签有索引的作用。",
   "id": "da10d69f51d4d100"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:27:44.098019Z",
     "start_time": "2025-01-25T13:27:44.089813Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 可以通过list创建Series，默认没有名称，且默认会使用一个从0开始自增的int作为index\n",
    "pd.Series([1,2,3,4,5])"
   ],
   "id": "47b113808db26cf2",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1\n",
       "1    2\n",
       "2    3\n",
       "3    4\n",
       "4    5\n",
       "dtype: int64"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:29:40.184984Z",
     "start_time": "2025-01-25T13:29:40.179265Z"
    }
   },
   "cell_type": "code",
   "source": "pd.Series([1,2,3,4,5], name='number') # 通过关键字参数name指定名称",
   "id": "ef01f7909a3b6317",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1\n",
       "1    2\n",
       "2    3\n",
       "3    4\n",
       "4    5\n",
       "Name: number, dtype: int64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:28:57.814779Z",
     "start_time": "2025-01-25T13:28:57.809640Z"
    }
   },
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    1\n",
      "b    2\n",
      "c    3\n",
      "d    4\n",
      "e    5\n",
      "dtype: int64\n",
      "Index(['a', 'b', 'c', 'd', 'e'], dtype='object')\n",
      "1\n"
     ]
    }
   ],
   "execution_count": 3,
   "source": [
    "# 创建时指定索引\n",
    "s = pd.Series([1,2,3,4,5], index=['a','b','c','d','e'])\n",
    "print(s)\n",
    "print(s.index)\n",
    "print(s['a'])"
   ],
   "id": "f6fe8677b0121679"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:30:39.107825Z",
     "start_time": "2025-01-25T13:30:39.101410Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 也可以通过dict创建Series，这时默认将key作为index，对应的value作为值\n",
    "d = {\n",
    "    'aa': 1,\n",
    "    'bb': 2,\n",
    "    'cc': 3,\n",
    "}\n",
    "pd.Series(d)"
   ],
   "id": "e223f0fd45345c57",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "aa    1\n",
       "bb    2\n",
       "cc    3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:33:09.366389Z",
     "start_time": "2025-01-25T13:33:09.360268Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 当然也可以通过numpy的ndarray创建Series\n",
    "import numpy as np\n",
    "s = pd.Series(np.array([1,2,3,4,5]))\n",
    "s.name = 'number' # 通过name属性直接修改\n",
    "s"
   ],
   "id": "95e50a79a8e02572",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1\n",
       "1    2\n",
       "2    3\n",
       "3    4\n",
       "4    5\n",
       "Name: number, dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "#### DataFrame",
   "id": "5f8796b38ad67e6"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "Series 是一维的数据结构，DataFrame 是一个表格型的数据结构，它含有不同的列，每列都可以是不同的数据类型。我们可以把 DataFrame 看作 Series 组成的字典（其中key为每个Series的name，也即DataFrame的列名，value就是每个Series），它既有行索引也有列索引。想象得更明白一点，它类似一张 excel 表格或者 SQL，只是功能更强大。",
   "id": "18bbe122d309d68c"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:36:16.094997Z",
     "start_time": "2025-01-25T13:36:16.086134Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 用 dict 创建 DataFrame，此时key就是每一列的列名，value必须是一个list或者tuple，长度都要一致\n",
    "dic = {\n",
    "    'name': ['张三', '李四', '王五'],\n",
    "    'age': [18, 19, 20],\n",
    "    'gender': ['male', 'female', 'female']\n",
    "}\n",
    "df = pd.DataFrame(dic, index = ['a', 'b', 'c'])\n",
    "df"
   ],
   "id": "c2838c5f73f16fb1",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "  name  age  gender\n",
       "a   张三   18    male\n",
       "b   李四   19  female\n",
       "c   王五   20  female"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>gender</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>张三</td>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>李四</td>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>王五</td>\n",
       "      <td>20</td>\n",
       "      <td>female</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 12
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:36:38.339897Z",
     "start_time": "2025-01-25T13:36:38.326263Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# .info() 查看数据概况····\n",
    "df.info()\n",
    "# 最后一行是 DataFrame 占用的内存大小，对于 pandas 来说，大数据也可以存取"
   ],
   "id": "7789a412ebb6bce9",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 3 entries, a to c\n",
      "Data columns (total 3 columns):\n",
      " #   Column  Non-Null Count  Dtype \n",
      "---  ------  --------------  ----- \n",
      " 0   name    3 non-null      object\n",
      " 1   age     3 non-null      int64 \n",
      " 2   gender  3 non-null      object\n",
      "dtypes: int64(1), object(2)\n",
      "memory usage: 96.0+ bytes\n"
     ]
    }
   ],
   "execution_count": 13
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:37:26.397049Z",
     "start_time": "2025-01-25T13:37:26.389523Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 通过head()得到前几行（默认5），相应的有tail()\n",
    "df.head(2), df.tail(2)"
   ],
   "id": "e69b688d8024f038",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(  name  age  gender\n",
       " a   张三   18    male\n",
       " b   李四   19  female,\n",
       "   name  age  gender\n",
       " b   李四   19  female\n",
       " c   王五   20  female)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 16
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:38:26.611177Z",
     "start_time": "2025-01-25T13:38:26.604647Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 通过列名获取某一列，得到一个Series\n",
    "df['name'], type(df['name'])"
   ],
   "id": "af4ded99b7eddcd7",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(a    张三\n",
       " b    李四\n",
       " c    王五\n",
       " Name: name, dtype: object,\n",
       " pandas.core.series.Series)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 19
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:38:56.585373Z",
     "start_time": "2025-01-25T13:38:56.556553Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 可以直接通过索引访问的方式新增一列\n",
    "df['Country'] = 'China' # 自动广播\n",
    "df"
   ],
   "id": "24ebbf58767f2c1b",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "  name  age  gender Country\n",
       "a   张三   18    male   China\n",
       "b   李四   19  female   China\n",
       "c   王五   20  female   China"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>gender</th>\n",
       "      <th>Country</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>张三</td>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>China</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>李四</td>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>China</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>王五</td>\n",
       "      <td>20</td>\n",
       "      <td>female</td>\n",
       "      <td>China</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 20
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:40:43.385951Z",
     "start_time": "2025-01-25T13:40:43.380248Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 使用iloc通过行号（下标从0开始）对数据进行索引\n",
    "df.iloc[0]"
   ],
   "id": "f586abfbadf2ed3b",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "name          张三\n",
       "age           18\n",
       "gender      male\n",
       "Country    China\n",
       "Name: a, dtype: object"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 21
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:40:57.654141Z",
     "start_time": "2025-01-25T13:40:57.647328Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 注意不能通过如下的方式访问“张三”的值\n",
    "df.iloc[0][0]"
   ],
   "id": "ee82bc1c8f32f548",
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_22863/3629555008.py:1: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
      "  df.iloc[0][0]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'张三'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 22
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:41:29.628746Z",
     "start_time": "2025-01-25T13:41:29.622085Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 而是通过这样的方式（第0行的列名为name的元素）\n",
    "df.iloc[0]['name']"
   ],
   "id": "31f6c68543d09f0a",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'张三'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 23
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:48:20.202694Z",
     "start_time": "2025-01-25T13:48:20.197439Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 或者这样的方式（第0行，第0列）\n",
    "df.iloc[0, 0]"
   ],
   "id": "b6b8a843b3d3976e",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'张三'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 34
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:44:00.003038Z",
     "start_time": "2025-01-25T13:43:59.993408Z"
    }
   },
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "name          张三\n",
       "age           18\n",
       "gender      male\n",
       "Country    China\n",
       "Name: a, dtype: object"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 27,
   "source": [
    "# 使用loc通过index和列名访问元素\n",
    "df.loc['a']"
   ],
   "id": "e04eafb3ef465c2c"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:44:26.383632Z",
     "start_time": "2025-01-25T13:44:26.375712Z"
    }
   },
   "cell_type": "code",
   "source": "df.loc[['a', 'b'], ['name', 'gender']] # 分别根据行索引和列名定位",
   "id": "31a0d34bd8f65947",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "  name  gender\n",
       "a   张三    male\n",
       "b   李四  female"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>gender</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>张三</td>\n",
       "      <td>male</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>李四</td>\n",
       "      <td>female</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 29
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:44:51.438138Z",
     "start_time": "2025-01-25T13:44:51.430314Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 可以利用loc对DataFrame进行过滤，得到满足条件的行\n",
    "df.loc[(df.age < 20) & (df.gender == 'male')]"
   ],
   "id": "76c5e1ee5910a6b3",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "  name  age gender Country\n",
       "a   张三   18   male   China"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>gender</th>\n",
       "      <th>Country</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>张三</td>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>China</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 30
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:45:21.756843Z",
     "start_time": "2025-01-25T13:45:21.735578Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 如下是等价的方法，age和gender必须都是列名\n",
    "df.query('age < 20 and gender == \"male\"')"
   ],
   "id": "66cac4f4bfd06f9d",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "  name  age gender Country\n",
       "a   张三   18   male   China"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>gender</th>\n",
       "      <th>Country</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>张三</td>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>China</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 31
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-25T13:47:19.308041Z",
     "start_time": "2025-01-25T13:47:19.296930Z"
    }
   },
   "cell_type": "code",
   "source": "df.ix[0][0]",
   "id": "a03f2a9af46479ea",
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'DataFrame' object has no attribute 'ix'",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mAttributeError\u001B[0m                            Traceback (most recent call last)",
      "\u001B[0;32m/tmp/ipykernel_22863/1283336172.py\u001B[0m in \u001B[0;36m?\u001B[0;34m()\u001B[0m\n\u001B[0;32m----> 1\u001B[0;31m \u001B[0mdf\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mix\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0;36m0\u001B[0m\u001B[0;34m]\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0;36m0\u001B[0m\u001B[0;34m]\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m",
      "\u001B[0;32m~/anaconda3/envs/jrrg/lib/python3.10/site-packages/pandas/core/generic.py\u001B[0m in \u001B[0;36m?\u001B[0;34m(self, name)\u001B[0m\n\u001B[1;32m   6295\u001B[0m             \u001B[0;32mand\u001B[0m \u001B[0mname\u001B[0m \u001B[0;32mnot\u001B[0m \u001B[0;32min\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_accessors\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   6296\u001B[0m             \u001B[0;32mand\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_info_axis\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_can_hold_identifiers_and_holds_name\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mname\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   6297\u001B[0m         ):\n\u001B[1;32m   6298\u001B[0m             \u001B[0;32mreturn\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0mname\u001B[0m\u001B[0;34m]\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 6299\u001B[0;31m         \u001B[0;32mreturn\u001B[0m \u001B[0mobject\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m__getattribute__\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mself\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mname\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m",
      "\u001B[0;31mAttributeError\u001B[0m: 'DataFrame' object has no attribute 'ix'"
     ]
    }
   ],
   "execution_count": 33
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "d385818aed4400c1"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
